
let viewFolder = '../views'
let componentsFolder = '../components'
const getComponentPathTree = ()=> {

    const routeAllPathToCompMap = import.meta.glob(`../views/**/*.vue`);
    let pathList = []
    for (let key in routeAllPathToCompMap) {
        let path = key.substring(viewFolder.length);
        path = path.substring(0, path.indexOf(".vue"));
        pathList.push(path)
    }
    return pathList
}


const getComponentMap =()=> {
    const routeAllPathToCompMap = import.meta.glob(`../views/**/*.vue`);

    const allComponentsMap = import.meta.glob("../components/**/*.vue");

    let componentMap = new Map();
    for (let key in routeAllPathToCompMap) {
        let path = key.substring(viewFolder.length);
        path = path.substring(0, path.indexOf(".vue"));
        componentMap.set(path, routeAllPathToCompMap[key]);
    }

    for(let key in allComponentsMap){
        let path = key.substring(componentsFolder.length);
        path = path.substring(0, path.indexOf(".vue"));
        componentMap.set(path, allComponentsMap[key]);
    }

    return componentMap
}
const AppUtil = {
    getComponentPathTree,getComponentMap
}
export default AppUtil
